package com.renjian.spring.day03.testdemo;

import com.renjian.spring.day03.config.SpringConfig;
import com.renjian.spring.day03.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Test {

    @org.junit.Test
    public void test1(){
        ApplicationContext context=
                new ClassPathXmlApplicationContext("com/renjian/spring/day03/bean1.xml");
        UserService userService = context.getBean("userService", UserService.class);
        userService.add();
    }

    @org.junit.Test
    public void test(){
        //加载配置类
        ApplicationContext context=
                new AnnotationConfigApplicationContext(SpringConfig.class);
        UserService userService = context.getBean("userService", UserService.class);
        System.out.println(userService);
        userService.add();
    }

}
